package com.hogocloud.corelibrary.weight

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.viewpager.widget.ViewPager

class CustomViewPager : ViewPager {

    // the sliding page switch
    private var isSlidingEnable = true

    constructor(context: Context) : super(context)

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs)

    //重写此函数
    override fun onTouchEvent(ev: MotionEvent): Boolean {
        return this.isSlidingEnable && super.onTouchEvent(ev)
    }

    //重写此函数
    override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
        return this.isSlidingEnable && super.onInterceptTouchEvent(ev)
    }

    fun setSlidingEnable(slidingEnable: Boolean) {
        isSlidingEnable = slidingEnable
    }
}